package me.leiusual.sharing.widget

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatButton

/**
 * Create by leiusual on 2018/7/22
 */
class ProgressButton @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : AppCompatButton(context, attrs, defStyleAttr) {

  private var oldText: CharSequence? = null
  private var progressText: CharSequence? = null

  override fun setEnabled(enabled: Boolean) {
    super.setEnabled(enabled)

    if (oldText == null) {
      oldText = text
    }

    if (progressText == null) {
      progressText = "处理中..."
    }

    text = if (enabled) oldText else progressText
  }
}